/*
 * ProductBO.java
 *
 * Created on March 5, 2007, 8:11 PM
 *
 * 
 */

package edu.byu.isys413.group1E.data;

import edu.byu.isys413.group1E.handlers.ConnectionPoolException;
import edu.byu.isys413.group1E.handlers.DataException;
import java.sql.SQLException;

/**Stores information about the Revenue Source object, which is inherited by 
 * several individual revenue sources.
 *
 * @author Kendall Frazier
 */
public abstract class ProductBO {
    
    private String productID; 
    private String SKU;
    private double price;
    private String prodType;
    boolean alreadyInDB;
    boolean dirty;
    
    /** Gets the productID from the ProductBO parent class, not the ConceptualBO
     * or PhysicalBO subclasses.
     *@return productID from the ProductBO, NOT from the the PhycisicalBO or 
     * ConeptualBO.  
     */
    public String getProductID(){
        return this.productID;
    }

    /** Sets the Product ID
     *@param productID contains the id for this product
     */
    public void setProductID(String productID){
        this.productID = productID;
        setDirty(true);
    }

    /** Retrieves the price of the product item
     *@return price
     */
    public double getPrice(){
        return this.price;
    }

    /** Sets the price of the product item
     *@param price contains the price for this product
     */
    public void setPrice(double price){
        setDirty(true);
        this.price = price;
    }
         
    /** Sets the alreadyInDB variable to indicate that 
     * the information contained in this object has been stored in the database
     *@param is indicates if this object has already been saved to the db
     */
    public void setAlreadyInDB(boolean is){
        setDirty(true);
        this.alreadyInDB = is;
    }

    /** Returns if the information contained in this object has already been stored in the database
     *@return alreadyInDB
     */
    public boolean isAlreadyInDB(){
        return alreadyInDB;
    }

    /** Returns if information has been changed within this object
     *@return isDirty
     */
    public boolean getDirty() {
        return dirty;
    }

    /** Sets the variable isDirty to indicate that some information has been modified or changed
     *in this object
     *@param isDirty indicates if data has changed
     */
    public void setDirty(boolean dirty) {
        this.dirty = dirty;
    }  

    /**gets the ProductType
     * 
     * @return prodType
     */
    public String getProdType() {
        return prodType;
    }

    /**sets the Product Type
     * 
     * @param prodType 
     */
    public void setProdType(String prodType) {
        this.prodType = prodType;
        setDirty(true);
    }

    /**gets the SKU
     * 
     * @return SKU
     */
    public String getSKU() {
        return SKU;
    }

    /**sets the SKU
     * 
     * @param SKU 
     */
    public void setSKU(String SKU) {
        this.SKU = SKU;
        setDirty(true);
    }
    
        public ConceptualRentalBO getCRBO() {
            ConceptualRentalBO crBO = null;
        try {
            crBO =  (ConceptualRentalBO)(ConceptualBO)ConceptualRentalDAO.getInstance().read(this.getProductID());
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (DataException ex) {
            ex.printStackTrace();
        } catch (ConnectionPoolException ex) {
            ex.printStackTrace();
        }
            return crBO;
    }
        
}//end product BO class
